/***************************************************************************
 *   Copyright (C) 2007 by Leonid Krashenko   *
 *   Leonid.Krashenko@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef TODOITEM_H
#define TODOITEM_H

#include <qlistview.h>
#include <qpalette.h>
#include <qpainter.h>

/**
	@author Leonid Krashenko <Leonid.Krashenko@gmail.com>
*/
class ToDoItem : public QCheckListItem
{
	public:
	    ToDoItem(QListView* parent, const QString& name);
		ToDoItem(QListViewItem* parent, const QString& name);
		
		void calculateParams();
		void setPercentComplete(int amount); 
		void increaseCompletion(int amount);
		void decreaseCompletion(int amount);
		void increasePriority(int amount);
		void decreasePriority(int amount);
		void setPriority(int priority);
		void setName(const QString&);
		void setContent(const QString&);
		
		int getPercentComplete() const;
		int getPriority() const;
		QString getContent() const;
		QString getName() const;
		
		void toggle();
		void completeChildren(bool);
		void updateToRoot();
		void update();
		
		void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align );
		
		void beginChange() {stateChanging = true;}
		static bool stateChanging;
		void endChange() {stateChanging = false;}
		
	private:
		void init();
		
		float _percentComplete;
		float _priority;
		QString _name;
		QString _content;
		
	protected:
		void stateChange(bool);
//		void activate();
};

#endif
